package com.ruoyi.gzp.controller;

import com.ruoyi.common.utils.tree.TreeAbleUtils;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.service.ISysDeptService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/tree")
@RequiredArgsConstructor
public class TreeController extends BaseController {

    private final ISysDeptService sysDeptService;

    @GetMapping("/list")
    public R list() {
        List<SysDept> sysDepts = sysDeptService.selectDeptList(new SysDept());
        List<SysDept> sysDept11 = TreeAbleUtils.buildChildren(sysDepts);
        return R.ok(sysDept11);
    }
}
